<?php

/**
 * This is the model class for table "hy_b_link".
 *
 * The followings are the available columns in table 'hy_b_link':
 * @property string $LinkID
 * @property string $LinkName
 * @property string $CateID
 * @property string $LinkUrl
 * @property string $LogoPic
 * @property integer $IsPic
 * @property integer $SortNum
 * @property string $Lang
 * @property integer $PublishDate
 */
class HyBLink extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return HyBLink the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'hy_b_link';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('IsPic, SortNum, PublishDate', 'numerical', 'integerOnly'=>true),
			array('LinkName', 'length', 'max'=>50),
			array('CateID', 'length', 'max'=>30),
			array('LinkUrl, LogoPic', 'length', 'max'=>255),
			array('Lang', 'length', 'max'=>10),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('LinkID, LinkName, CateID, LinkUrl, LogoPic, IsPic, SortNum, Lang, PublishDate', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'LinkID' => 'Link',
			'LinkName' => 'Link Name',
			'CateID' => 'Cate',
			'LinkUrl' => 'Link Url',
			'LogoPic' => 'Logo Pic',
			'IsPic' => 'Is Pic',
			'SortNum' => 'Sort Num',
			'Lang' => 'Lang',
			'PublishDate' => 'Publish Date',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('LinkID',$this->LinkID,true);
		$criteria->compare('LinkName',$this->LinkName,true);
		$criteria->compare('CateID',$this->CateID,true);
		$criteria->compare('LinkUrl',$this->LinkUrl,true);
		$criteria->compare('LogoPic',$this->LogoPic,true);
		$criteria->compare('IsPic',$this->IsPic);
		$criteria->compare('SortNum',$this->SortNum);
		$criteria->compare('Lang',$this->Lang,true);
		$criteria->compare('PublishDate',$this->PublishDate);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}